package com.lili.goods.controller;


import com.lili.goods.service.GoodsSpecValuesService;
import com.lili.model.goods.GoodsSpecValues;
import com.lili.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
@Api(tags = "商品规格值")
public class GoodsSpecValuesController {
    @Autowired
    GoodsSpecValuesService goodsSpecValuesService;

    @ApiOperation("商品规格值查询")
    @GetMapping("/specValues")
    public Result getGoodsSpecValues() {
        List<GoodsSpecValues> list = goodsSpecValuesService.getSpecValues();
        return Result.ok(list);
    }

    @ApiOperation("商品规格值保存")
    @PostMapping("/specValues")
    public Result saveGoodsSpecValues(@RequestBody GoodsSpecValues goodsSpecValues) {
        int i = goodsSpecValuesService.saveSpecValues(goodsSpecValues);
        return Result.ok("保存成功" + i);
    }


    @ApiOperation("商品规格值更新")
    @PutMapping("/specValues")
    public Result updateGoodsSpecValues(@RequestBody GoodsSpecValues goodsSpecValues) {
        int i = goodsSpecValuesService.updateSpecValues(goodsSpecValues);
        return Result.ok("更新成功" + i);
    }


    @ApiOperation("商品规格值删除")
    @DeleteMapping("/specValues")
    public Result deleteGoodsSpecValues(@RequestBody GoodsSpecValues goodsSpecValues) {
        int i = goodsSpecValuesService.deleteSpecValues(goodsSpecValues);
        return Result.ok("删除成功" + i);
    }


}
